package org.example.net;

import lombok.SneakyThrows;

import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * @Auther:Liu
 * @Testname:DemoA1
 * @Date:2025/8/27 17:20
 */
public class DemoA1 {
    @SneakyThrows
    public static void main(String[] args) {
        System.out.println("开启通讯");
        //服务端 指定端口
        ServerSocket serverSocket = new ServerSocket(8888);
        System.out.println("开启了服务"+serverSocket);
        //开启一个通讯
        Socket socket = serverSocket.accept();
        //发送内容
        OutputStream outputStream = socket.getOutputStream();
        String message="123";
        outputStream.write(message.getBytes(StandardCharsets.UTF_8));
    }
}
